{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "1ae5431d-4c7a-4abf-bcba-ec82218351f7",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<RequestsCookieJar[<Cookie gitee-session-n=eWUxRGdHTE4zekdqazczc2IyNlB5TkxJcVlrM004SldPVTdoMmt5bGd5YjE3MGo2Y1BjbDBaOVVWNWxSUDNsRlpHQVJVV3ZDNmljUU04aTNFME56MGoxNWU0MTZzWDAvMFZqQ2k1ZEtZTFlwWE05OE5BV2N2WHNVY2lWNkt3elBEVHFMcW9hUmJIVmc4UzRwZzdjRTVYWDgzUXVrZGY3QlJHSWxTZll2R01kZmpabnBzQ2hZUXZreXdLYXJWbms0LS1uTGNFNzNnTlVUOFljam1vWUlBVDd3PT0%3D--82a5287ebf7dfb4554f7a2201e0c50f89d2e3704 for .gitee.com/>, <Cookie user_locale=zh-CN for .gitee.com/>, <Cookie oschina_new_user=false for gitee.com/>]>\n",
      "{'Date': 'Thu, 18 Nov 2021 14:46:38 GMT', 'Content-Type': 'text/html; charset=utf-8', 'Transfer-Encoding': 'chunked', 'Connection': 'keep-alive', 'Keep-Alive': 'timeout=60', 'Server': 'nginx', 'Vary': 'Accept-Encoding', 'X-XSS-Protection': '1; mode=block', 'X-Content-Type-Options': 'nosniff', 'X-UA-Compatible': 'chrome=1', 'Expires': 'Sun, 1 Jan 2000 01:00:00 GMT', 'Pragma': 'must-revalidate, no-cache, private', 'Cache-Control': 'no-cache', 'Set-Cookie': 'user_locale=zh-CN; domain=.gitee.com; path=/; expires=Mon, 18 Nov 2041 14:46:38 -0000, oschina_new_user=false; path=/; expires=Mon, 18 Nov 2041 14:46:38 -0000, gitee-session-n=eWUxRGdHTE4zekdqazczc2IyNlB5TkxJcVlrM004SldPVTdoMmt5bGd5YjE3MGo2Y1BjbDBaOVVWNWxSUDNsRlpHQVJVV3ZDNmljUU04aTNFME56MGoxNWU0MTZzWDAvMFZqQ2k1ZEtZTFlwWE05OE5BV2N2WHNVY2lWNkt3elBEVHFMcW9hUmJIVmc4UzRwZzdjRTVYWDgzUXVrZGY3QlJHSWxTZll2R01kZmpabnBzQ2hZUXZreXdLYXJWbms0LS1uTGNFNzNnTlVUOFljam1vWUlBVDd3PT0%3D--82a5287ebf7dfb4554f7a2201e0c50f89d2e3704; domain=.gitee.com; path=/; HttpOnly', 'X-Request-Id': 'ee42ad853621d131abf9b2b6bbdb84c3', 'X-Runtime': '0.223942', 'X-Frame-Options': 'SAMEORIGIN', 'Content-Encoding': 'gzip'}\n",
      "刷新成功\n"
     ]
    }
   ],
   "source": [
    "\"\"\"\n",
    "自动刷新mb的gitee pages服务\n",
    "https://gitee.com/mgang/mb/pages/rebuild\n",
    "branch: master\n",
    "build_directory:\n",
    "force_https: false\n",
    "auto_update: false\n",
    "\n",
    "encrypt_key: password\n",
    "utf8: ✓\n",
    "authenticity_token: Mz9VFgSvpk91yd6CzJaZBHh2DEWlQDUSpJeCiw5/ewtMcspz5Efk3+t4n7l5wY9pxyFrqHoOTbCtBsTQgJmG6Q==\n",
    "redirect_to_url: \n",
    "user[login]: 1092017732@qq.com\n",
    "encrypt_data[user[password]]: G+YB9wWLo1iFqAjTGg4PJejm1YldDOrRNcAd34A0o6d1Cx2OurCQU0O1YPiQ6geupnVOBHW5dKp4/QhHqDQCBbXI8loVFBDHhWfpCxhle72zRjzI+LOp3yEgxoh1IDXWEZUng1AFPQCDzH+oE2/BQIJuTXurnfkhaSy0w0xKZ1Q=\n",
    "user[remember_me]: 0\n",
    "\"\"\"\n",
    "\n",
    "\n",
    "import requests\n",
    "# 获取登录后的\n",
    "#token = 'Mz9VFgSvpk91yd6CzJaZBHh2DEWlQDUSpJeCiw5/ewtMcspz5Efk3+t4n7l5wY9pxyFrqHoOTbCtBsTQgJmG6Q=='\n",
    "#loginParam = {'user_login':'1092017732@qq.com'}\n",
    "#loginParam = {\n",
    "#    'encrypt_key': 'password',\n",
    "#    'utf8': '✓',\n",
    "#    'authenticity_token': token,\n",
    "#    'redirect_to_url':'', \n",
    "#    'user[login]': '1092017732@qq.com',\n",
    "#    'encrypt_data[user[password]]': 'G+YB9wWLo1iFqAjTGg4PJejm1YldDOrRNcAd34A0o6d1Cx2OurCQU0O1YPiQ6geupnVOBHW5dKp4/QhHqDQCBbXI8loVFBDHhWfpCxhle72zRjzI+LOp3yEgxoh1IDXWEZUng1AFPQCDzH+oE2/BQIJuTXurnfkhaSy0w0xKZ1Q=',\n",
    "#    'user[remember_me]': '0'\n",
    "#}\n",
    "#loginResult = requests.post('https://gitee.com/login',params=loginParam)\n",
    "#gsn = loginResult.cookies['gitee-session-n']\n",
    "#oschina_new_user = loginResult.cookies['oschina_new_user']\n",
    "#user_locale = loginResult.cookies['user_locale']\n",
    "print(loginResult.cookies)\n",
    "print(loginResult.headers)\n",
    "#print(loginResult.text)\n",
    "#cookieStr = 'user_locale=zh-CN; oschina_new_user='+oschina_new_user+\"; gitee-session-n=\"+gsn\n",
    "#print(cookieStr)\n",
    "header = {\n",
    "    'Accept': '*/*',\n",
    "    'Accept-Encoding': 'gzip, deflate, br',\n",
    "    'Accept-Language': 'zh-CN,zh;q=0.9',\n",
    "    'Connection': 'keep-alive',\n",
    "    'Content-Length': '89',\n",
    "    'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',\n",
    "    'Cookie': 'oschina_new_user=false; yp_riddler_id=1fc6e7a9-3827-40dc-af09-8360e69ce24d; close_wechat_tour=true; remote_way=ssh; user_locale=zh-CN; tz=Asia%2FShanghai; sensorsdata2015jssdkcross=%7B%22distinct_id%22%3A%22122375%22%2C%22first_id%22%3A%2217abcb4d3ec42e-05a960c7c38f4c-34647600-1764000-17abcb4d3edaa0%22%2C%22props%22%3A%7B%22%24latest_traffic_source_type%22%3A%22%E5%BC%95%E8%8D%90%E6%B5%81%E9%87%8F%22%2C%22%24latest_search_keyword%22%3A%22%E6%9C%AA%E5%8F%96%E5%88%B0%E5%80%BC%22%2C%22%24latest_referrer%22%3A%22http%3A%2F%2Fgit.oschina.net%2Fmgang%22%2C%22%24latest_utm_source%22%3A%22alading%22%2C%22%24latest_utm_campaign%22%3A%22repo%22%7D%2C%22%24device_id%22%3A%2217abcb4d3ec42e-05a960c7c38f4c-34647600-1764000-17abcb4d3edaa0%22%7D; Hm_lvt_24f17767262929947cc3631f99bfd274=1636860426,1636863976,1637156499,1637158987; gitee_user=true; gitee-session-n=ejdoMUQ2OW1PYm5PNzRMVkYxN0oxSTBDS2lyL01oUkZjTXRpOHRJZjlBMXJwcXJVUXZMYlR3a2RoM29VR3diQkdPdmMzanM1RERIY28vR3l4YjViRExRc21naGFkK2VkQmgvU05jSjlId0tuWFVrTTQyYWxTY0hwbzZTcWg2TmVjSUNmTHdrcEc1aGhTSU1hQmxzTTNpM0Q1eTVCN1VaRldiZkNMeEt2S0ZtbTMvbHFQeXpDcmp2amYyVEJnZ1lGUDhFNnVZRlQreWFwZE5QZlhOVlRNc3lXaDBoaDVBeG4vSFp5T0o2OEhodk5OeFd1WEx4YVVDRmU3dVBoQ3kxSnVhQTlLVXpoZWROUVVJR1RRZ05xbmE5K0ljQnlNdlN5RDQ0ejNERWwvQnErY2pXUTFndUIrSUNwNVMxalJqMWNEYXBEUSt0aUtRaVJST051WEN3czZ1d2RoYUFJZzc1bisrV3B1TlcwWDhjPS0tZVdwTmErOHlXbFZ3N000VnF0ZEIxZz09--beae159dc443c2d6ee85ec0a2f3bae0a991795a9; Hm_lpvt_24f17767262929947cc3631f99bfd274=1637159902',\n",
    "    'Sec-Fetch-Dest': 'empty',\n",
    "    'Sec-Fetch-Mode': 'cors',\n",
    "    'Sec-Fetch-Site': 'same-origin',\n",
    "    'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.193 Safari/537.36',\n",
    "    'X-CSRF-Token': 'Z05EF2kJRP2xwHMpkNQ+QaQfI+rAmdpG4yiYy7IhnzTiiUaO3TWbngZ6dViaiTG/yOGmrHEt2v1rmcrLVahI5w==',\n",
    "    'X-Requested-With': 'XMLHttpRequest'\n",
    "}\n",
    "data = {'branch': 'master', 'build_directory': 'docs/.vuepress/dist','force_https': 'false','auto_update': 'false'}\n",
    "r = requests.post(\"https://gitee.com/mgang/plan/pages/rebuild\",data,headers=header)\n",
    "if r.status_code == 200:\n",
    "    print(\"刷新成功\")\n",
    "else:\n",
    "    print(\"重新部署失败，\"+r.text)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a89bf919-9cd5-4327-8199-01d3ab1fc9f0",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.13"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
